package o;

import com.huawei.hms.framework.network.restclient.hwhttp.dns.DnsConfig;
import com.tencent.mm.opensdk.constants.ConstantsAPI.AppSupportContentFlag;
import java.io.IOException;

public final class aeq {
    private final anc ˋ = new anc(8);
    private int ॱ;

    public boolean ॱ(adv o_adv) throws IOException, InterruptedException {
        long ॱ = o_adv.ॱ();
        long j = (ॱ == -1 || ॱ > AppSupportContentFlag.MMAPP_SUPPORT_XLS) ? AppSupportContentFlag.MMAPP_SUPPORT_XLS : ॱ;
        int i = (int) j;
        o_adv.ˎ(this.ˋ.ˏ, 0, 4);
        j = this.ˋ.ˋॱ();
        this.ॱ = 4;
        while (j != 440786851) {
            int i2 = this.ॱ + 1;
            this.ॱ = i2;
            if (i2 == i) {
                return false;
            }
            o_adv.ˎ(this.ˋ.ˏ, 0, 1);
            j = ((j << 8) & -256) | ((long) (this.ˋ.ˏ[0] & 255));
        }
        j = ˊ(o_adv);
        long j2 = (long) this.ॱ;
        if (j == Long.MIN_VALUE) {
            return false;
        }
        if (ॱ != -1 && j2 + j >= ॱ) {
            return false;
        }
        while (((long) this.ॱ) < j2 + j) {
            if (ˊ(o_adv) == Long.MIN_VALUE) {
                return false;
            }
            ॱ = ˊ(o_adv);
            if (ॱ < 0 || ॱ > 2147483647L) {
                return false;
            }
            if (ॱ != 0) {
                int i3 = (int) ॱ;
                o_adv.ˊ(i3);
                this.ॱ = i3 + this.ॱ;
            }
        }
        return ((long) this.ॱ) == j + j2;
    }

    private long ˊ(adv o_adv) throws IOException, InterruptedException {
        int i = 0;
        o_adv.ˎ(this.ˋ.ˏ, 0, 1);
        int i2 = this.ˋ.ˏ[0] & 255;
        if (i2 == 0) {
            return Long.MIN_VALUE;
        }
        int i3 = DnsConfig.MAX_CACHE_ENTRIES;
        int i4 = 0;
        while ((i2 & i3) == 0) {
            i4++;
            i3 >>= 1;
        }
        i3 = (i3 ^ -1) & i2;
        o_adv.ˎ(this.ˋ.ˏ, 1, i4);
        while (i < i4) {
            i3 = (i3 << 8) + (this.ˋ.ˏ[i + 1] & 255);
            i++;
        }
        this.ॱ += i4 + 1;
        return (long) i3;
    }
}
